package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Introduction;
import com.ruoyi.system.service.IIntroductionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 实验室简介Controller
 * 
 * @author ruoyi
 * @date 2024-12-30
 */
@RestController
@RequestMapping("/system/introduction")
public class IntroductionController extends BaseController
{
    @Autowired
    private IIntroductionService introductionService;

    /**
     * 查询实验室简介列表
     */
    @Anonymous
    @GetMapping("/list")
    public TableDataInfo list(Introduction introduction)
    {
        startPage();
        List<Introduction> list = introductionService.selectIntroductionList(introduction);
        return getDataTable(list);
    }

    /**
     * 导出实验室简介列表
     */
    @PreAuthorize("@ss.hasPermi('system:introduction:export')")
    @Log(title = "实验室简介", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Introduction introduction)
    {
        List<Introduction> list = introductionService.selectIntroductionList(introduction);
        ExcelUtil<Introduction> util = new ExcelUtil<Introduction>(Introduction.class);
        util.exportExcel(response, list, "实验室简介数据");
    }

    /**
     * 获取实验室简介详细信息
     */
    @Anonymous
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(introductionService.selectIntroductionById(id));
    }

    /**
     * 新增实验室简介
     */
    @PreAuthorize("@ss.hasPermi('system:post:add')")
    @Log(title = "实验室简介", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Introduction introduction)
    {
        return toAjax(introductionService.insertIntroduction(introduction));
    }

    /**
     * 修改实验室简介
     */
    @PreAuthorize("@ss.hasPermi('system:post:edit')")
    @Log(title = "实验室简介", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Introduction introduction)
    {
        return toAjax(introductionService.updateIntroduction(introduction));
    }

    /**
     * 删除实验室简介
     */
    @PreAuthorize("@ss.hasPermi('system:post:remove')")
    @Log(title = "实验室简介", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(introductionService.deleteIntroductionByIds(ids));
    }
}
